#!/bin/bash
set -eu
THIS="$(readlink -f "$0")"
THISDIR="$(dirname "${THIS}")"
SRCDIR="$(dirname "${THISDIR}")"
SUT="${SRCDIR}/makeself.sh"

setupTests() {
  temp=`mktemp -d -t XXXXX`
  cd "$temp"
  mkdir archive
  cp -a "$SRCDIR" archive/
  $SUT $* archive makeself-test.run "Test $*" echo Testing --tar-extra="--exclude .git"
}


testQuiet()
{
  setupTests

  ./makeself-test.run --quiet
  assertEquals $? 0
}

testGzip()
{
  setupTests --gzip
  
  ./makeself-test.run --check
  assertEquals $? 0
}

testBzip2()
{
  setupTests --bzip2
  
  ./makeself-test.run --check
  assertEquals $? 0
}

testPBzip2()
{
  # Skip if pbzip2 is not available
  which pbzip2 || startSkipping
  setupTests --pbzip2

  ./makeself-test.run --check
  assertEquals $? 0
}

testZstd()
{
  # Skip if zstd is not available
  which zstd || startSkipping
  setupTests --zstd

  ./makeself-test.run --check
  assertEquals $? 0
}

# Load and run shUnit2.
source "./shunit2/shunit2"

